package cn.kingleung;

import java.io.IOException;
import java.util.List;
import java.util.Map;

public class TestMain {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		Plist plist = Plist.getInstance();
		try {
			Map map = plist.load("C:\\Users\\kingleung\\Desktop\\Meeting4yjy.plist");
			TestMain.load(map);
			plist.store(map, "C:\\Users\\kingleung\\Desktop\\Meeting4yjy.plist");
			TestMain.load(map);
		} catch (XmlParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static void load(Map map) {
		List items = (List) map.get("items");
		for (Object item : items) {
			if (item instanceof Map ) {
				if (((Map) item).containsKey("assets")) {
					List assets = (List) ((Map) item).get("assets");
					for (Object asset : assets) {
						if (asset instanceof Map && ((Map) asset).containsKey("url")) {
							System.out.println(((Map) asset).get("url"));
							((Map) asset).put("url", "aaa");
						}
					}
				}
				if (((Map) item).containsKey("metadata")) {
					Map metadata = (Map) ((Map) item).get("metadata");
					if (metadata instanceof Map && ((Map) metadata).containsKey("bundle-identifier")) {
						System.out.println(((Map) metadata).get("bundle-identifier"));
					}
				}
			}
				
		}
	}

}
